package com.sg.hms.ServiceImpl;

import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.sg.hms.Dao.DepartmentDao;
import com.sg.hms.DaoImpl.DepartmentDaoImpl;
import com.sg.hms.Model.Department;
import com.sg.hms.Model.Department2;
import com.sg.hms.Service.DepartmentService;

public class DepartmentServiceImpl implements DepartmentService{
    
	private DepartmentDao dDao=new DepartmentDaoImpl();
	@Override
	public String selectDeNameBydId(int dId) {
		// TODO Auto-generated method stub
		return dDao.selectDeNameBydId(dId);
	}
	/**
	 * 获取所有的部门
	 */
	@Override
	public int getAllDepartmentsSize() {
		// TODO Auto-generated method stub
		return dDao.getAllDepartmentsSize();
	}
	/**
	 * 根据部门名字添加部门
	 */
	@Override
	public boolean insertDepartment(String dName) {
		// TODO Auto-generated method stub
		return dDao.insertDepartment(dName);
	}
	/**
	 *  修改部门
	 */
	@Override
	public boolean updateDepartment(String dName,int dId) {
		// TODO Auto-generated method stub
		return dDao.updateDepartment(dName, dId);
	}
	/**
	 * 根据部门编号删除部门
	 */
	@Override
	public boolean deleteDepartmentByDId(String[] dIds) {
		// TODO Auto-generated method stub
		return dDao.deleteDepartmentById(dIds);
	}
	/**
	 * 查询当前页面要显示的部门
	 */
	@Override
	public JSONObject selectDepartmentsBypage(int pageStart, int pageSize,int total) {
		// TODO Auto-generated method stub
		List<Department> departments = dDao.selectDepartmentsBypage(pageStart, pageSize);
		JSONObject departments2 = new JSONObject();
		departments2.put("rows", departments);
		departments2.put("total", total);
		return departments2;
	}


}
